package org.hp.intern.test;
import org.hp.intern.test.Producer;
import org.hp.intern.test.Consumer;
import org.hp.intern.test.Semaphore;

public class test1 {

	
    public static void main(String[] args){
		
        //表示可用的缓冲区个数
    	Semaphore empty = new Semaphore(10);
    	
        //表示放有产品的缓冲区个数
    	Semaphore full = new Semaphore(0);

        //表示独占信号量
    	Semaphore mutex = new Semaphore(1);
    	
    	Producer p1 = new Producer(full,empty,mutex);
        Consumer c1 = new Consumer(full,empty,mutex);
        Consumer c2 = new Consumer(full,empty,mutex); 
        Thread t1 = new Thread(p1);
        Thread t2 = new Thread(c1);
        Thread t3 = new Thread(c2);
        t1.start();
        t2.start();
        t3.start();
        
        try{
        System.in.read();
        }catch(Exception e ){
        	
        	System.out.println("a exception");
        }
            	
		
	}
	
}
